package leetcode1;

//删除有序数组重复项2
public class leetcode80 {
    class Solution {
        public int removeDuplicates(int[] nums) {
            int slow=0;
            int fast=1;
            int count=1;
            while(fast< nums.length){
                if(nums[fast]==nums[slow]&&count<2){
                    nums[++slow]=nums[fast];
                    count++;
                }
                else if(nums[fast]!=nums[slow]){
                    nums[++slow]=nums[fast];
                    count=1;
                }
                fast++;
            }
            return ++slow;
        }
    }
}
